Centos7 Redis自启动报错

错误日志如下

systemctl status redis.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
● redis.service - Redis persistent key-value database

Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)

Drop-In: /etc/systemd/system/redis.service.d

└─limit.conf

Active: failed (Result: exit-code) since Mon 2019-03-11 16:59:42 CST; 10s ago

Process: 5711 ExecStop=/usr/libexec/redis-shutdown (code=exited, status=1/FAILURE)

Process: 5709 ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd (code=exited, status=1/FAILURE)

Main PID: 5709 (code=exited, status=1/FAILURE)

Mar 11 16:59:42 iZj6c6ncdtlrfnzsy28pyiZ systemd[1]: Starting Redis persistent key-value database...

Mar 11 16:59:42 iZj6c6ncdtlrfnzsy28pyiZ systemd[1]: redis.service: main process exited, code=exited, status=1/FAILURE

Mar 11 16:59:42 iZj6c6ncdtlrfnzsy28pyiZ redis-shutdown[5711]: Could not connect to Redis at 127.0.0.1:6379: Connection refused

Mar 11 16:59:42 iZj6c6ncdtlrfnzsy28pyiZ systemd[1]: redis.service: control process exited, code=exited status=1

Mar 11 16:59:42 iZj6c6ncdtlrfnzsy28pyiZ systemd[1]: Failed to start Redis persistent key-value database.

Mar 11 16:59:42 iZj6c6ncdtlrfnzsy28pyiZ systemd[1]: Unit redis.service entered failed state.

Mar 11 16:59:42 iZj6c6ncdtlrfnzsy28pyiZ systemd[1]: redis.service failed.

查错

cat /lib/systemd/system/redis.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

//显示

[Unit]

Description=Redis persistent key-value database

After=network.target

[Service]

ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd

ExecStop=/usr/libexec/redis-shutdown

Type=notify

User=redis

Group=redis

RuntimeDirectory=redis

RuntimeDirectoryMode=0755

[Install]

WantedBy=multi-user.target

说明这个服务系统启动后是redis组的,所以改文件权限为redis组即可

解决方案

chown redis:redis /var/log/redis/redis.log

关注作者公众号,获取更多资源!
赏作者一杯咖啡~